package com.autumn.sms.service.controller;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.autumn.application.dto.PageQueryResult;
import com.autumn.application.dto.input.DefaultPrimaryKeyInput;
import com.autumn.sms.service.consts.UrlConsts;
import com.autumn.sms.service.services.ISmsAppTemplateService;
import com.autumn.sms.service.services.dto.input.PageQueryByAppInput;
import com.autumn.sms.service.services.dto.input.SmsAppTemplateInput;
import com.autumn.sms.service.services.dto.input.SmsAppTemplateUpdateInput;
import com.autumn.sms.service.services.dto.output.SmsAppTemplateOutput;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 *应用模板控制器
 * @author JuWa ▪ Zhang
 * @date 2018年1月17日
 * @since jdk 1.8
 */
@Api(tags = "短信后台-应用模板")
@RestController
@RequestMapping(UrlConsts.SMSAPP_TEMPLATE)
public class SmsAppTemplateController {
	
	@Autowired
	private ISmsAppTemplateService service;
	
	@GetMapping("/get")
	@ApiOperation("获取应用模板信息")
	public SmsAppTemplateOutput get(@Valid DefaultPrimaryKeyInput input) {
		return service.get(input);
	}
	
	@PostMapping("/add")
	@ApiOperation("新增应用模板信息")
	public SmsAppTemplateOutput add(@Valid @RequestBody SmsAppTemplateInput input) {
		return service.add(input);
	}
	
	@PostMapping("/modify")
	@ApiOperation("更新应用模板信息")
	public SmsAppTemplateOutput modify(@Valid @RequestBody SmsAppTemplateUpdateInput input) {
		return service.modify(input);
	}
	
	@PostMapping("/delete")
	@ApiOperation("/删除应用模板信息")
	public void delete(@Valid @RequestBody DefaultPrimaryKeyInput input) {
		service.delete(input);
	}
	
	@PostMapping("/release")
	@ApiOperation("发布应用模板信息")
	public void release(@Valid @RequestBody DefaultPrimaryKeyInput input) {
		service.release(input);
	}
	
	@PostMapping("/disable")
	@ApiOperation("停用应用模板")
	public void disable(@Valid @RequestBody DefaultPrimaryKeyInput input) {
		service.disable(input);
	}
	
	@PostMapping("/pagequery")
	@ApiOperation("根据应用ID和标准模板ID分页获取应用模板")
	public PageQueryResult<SmsAppTemplateOutput> pageQueryByAppId(@Valid @RequestBody PageQueryByAppInput input) {
		return service.pageQueryByAppId(input);
	}
}
